import Vue from "vue";
import Router from "vue-router";
import CategoryEdit from "../views/categoryEdit.vue";
import ItemEdit from "../views/itemEdit.vue";
import HeroEdit from "../views/HeroEdit.vue";
// import Main from '../views/Main.vue'

Vue.use(Router);

export default new Router({
  routes: [
    {
      path: "/",
      name: "main",
      component: () => import("@/views/Main.vue"),
      // 添加子路由
      children: [
        {
          path: "/categories/create",
          component: CategoryEdit,
          // component: () => import('@/views/categoryEdit.vue')
        },
        {
          path: "/categories/edit/:id",
          component: CategoryEdit,
          // 把URL参数，转到页面(页面要接收)
          props: true,
        },
        {
          path: "/categories/list",
          component: () => import("@/views/categoryList.vue"),
        },
        //
        {
          path: "/items/create",
          component: ItemEdit,
        },
        {
          path: "/items/edit/:id",
          component: ItemEdit,
          props: true,
        },
        {
          path: "/items/list",
          component: () => import("@/views/itemList.vue"),
        },

        //
        {
          path: "/heroes/create",
          component: HeroEdit,
        },
        {
          path: "/heroes/edit/:id",
          component: HeroEdit,
          props: true,
        },
        {
          path: "/heroes/list",
          component: () => import("@/views/HeroList.vue"),
        },
      ],
    },
  ],
});
